package com.fifth.apartment.controller;

import com.fifth.apartment.entity.Equipment;
import com.fifth.apartment.entity.EquipmentType;
import com.fifth.apartment.result.Result;
import com.fifth.apartment.service.EquipmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * TODO
 *
 * @author Dao
 * @since 2024/7/24
 */
@RestController
@RequestMapping("/app/type")
@Api(tags = "设备报修接口")
@Slf4j
public class TypeController {

    @Autowired
    private EquipmentService service;

    @GetMapping("findType")
    @ApiOperation("查找所有设备类型")
    public Result findType(){
        EquipmentType[] types = service.findType();
        if (types!=null){
            return new Result(true,"查找成功",types);
        }
        else {
            return new Result(false,"查找失败");
        }
    }

    @PostMapping("addEquipment")
    @ApiOperation("添加一个报修设备")
    public Result addEquipment(Equipment equipment){
        //System.out.println("-----equipment------"+equipment);
        Boolean flag = service.addEquipment(equipment);

        if (flag){
            return new Result(true,"添加成功");
        }else {
            return new Result(false,"添加失败");
        }

    }
}
